<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title style="height: 500px">朋友圈动态</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">


    <link rel="stylesheet" href="/css/myStrategyComment.css"/>
    <link rel="stylesheet" href="/css/app.css">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.css">
    <script src="/js/jquery/jquery.min.js" type="text/javascript"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <link rel="stylesheet" href="/js/jqueryAlert/common.css">
    <script src="/js/jqueryAlert/alertPopShow.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/checkLogin.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.js"></script>


    <style type="text/css">
        * {
            cursor: pointer;
        }

        .weui_mask_transition {
            display: none;
            position: fixed;
            z-index: 1;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            background: rgba(0, 0, 0, 0);
            -webkit-transition: background .3s;
            transition: background .3s;
        }

        .weui_fade_toggle {
            background: rgba(0, 0, 0, 0.6);
        }

        .weui_actionsheet {
            position: fixed;
            left: 0;
            bottom: 0;
            -webkit-transform: translate(0, 100%);
            -ms-transform: translate(0, 100%);
            transform: translate(0, 100%);
            -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
            z-index: 2;
            width: 100%;
            background-color: #EFEFF4;
            -webkit-transition: -webkit-transform .3s;
            transition: transform .3s;
        }

        .weui_actionsheet_toggle {
            -webkit-transform: translate(0, 0);
            -ms-transform: translate(0, 0);
            transform: translate(0, 0);
        }

        .weui_actionsheet_menu {
            background-color: #FFFFFF;
        }

        .weui_actionsheet_cell:before {
            content: " ";
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 1px;
            border-top: 1px solid #D9D9D9;
            -webkit-transform-origin: 0 0;
            -ms-transform-origin: 0 0;
            transform-origin: 0 0;
            -webkit-transform: scaleY(0.5);
            -ms-transform: scaleY(0.5);
            transform: scaleY(0.5);
        }

        .weui_actionsheet_cell:first-child:before {
            display: none;
        }

        .weui_actionsheet_cell {
            position: relative;
            padding: 10px 0;
            text-align: center;
            font-size: 18px;
        }

        .weui_actionsheet_cell.title {
            color: #999;
        }

        .weui_actionsheet_action {
            margin-top: 6px;
            background-color: #FFFFFF;
        }

    </style>

</head>
<body>


<script>
    $(function () {
        var currentPage =1;//默认第一页
        var pages; //总页数
        var travelArr = [];//用户存储游记文章的容器
        var loading = false;//标记是否查询中


        function query() {//分页查询
            if (loading) {//代表正在查询,就直接结束方法
                return;
            }
            loading = true;//标记正在查询中;
            $.get(baseUrl + "/dynamics",{currentPage: currentPage} ,function (data) {
                $.merge(travelArr,data.list );//合并数据,把第二个参数的数据合并到第一个参数的容器中
                var json = {list:travelArr};//用于render-loop="list"
                $("#list").renderValues(json,{
                    getDate: function (item, value) {
                        $(item).html(getDateDetail(value));
                    }
                });
                currentPage++;//当前页数+1
                pages = data.pages;//设置总页数
                loading = false;//标记查询结束

                //绑定图片的点击事件
                $(".list-img").click(function () {
                    //获取点击的图片
                    var src = $(this).attr('src');
                    $(document).dialog({
                        style: 'ios',
                        titleShow: false,
                        overlayClose: true,
                        content: '<img src="' + src + '" width="100%"/>'
                    });
                })
                //点击评论框进行评论操作
                $(".sss").click(function () {
                    $('#myModal').modal("show");
                });

            });
        }

        query();//默认查询第一页


        //监听窗口的滚动事件
        $(window).scroll(function () {
            console.log("窗口滚动中...")
            if($(document).scrollTop()+$(window).height() >= $(document).height()-1){//滚动到底部
                //如果已经查询到最后一页,就不再查
                if(currentPage<=pages) {
                    query();
                }else{
                    $(document).dialog({
                        type : 'notice',
                        content: '<span class="info-text">已经到底了!</span>',
                        autoClose: 1500
                    });
                }
            }
        })

        $(".btn-submit").click(function () {
            $("#editForm").ajaxSubmit(function (data) {
            });
        });


    })
</script>

<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div id="outerdiv"
                 style="position: fixed; top: 0; left: 0; background: rgba(0,0,0,0.7); z-index: 2; width: 100%; height: 100%; display: none;">
                <div id="innerdiv" style="margin:auto;width: 800px; height: 800px;margin-top:33%;">
                    <img id="bigimg" style="border: 5px solid #fff; margin: 0 auto;width: 366px; height: 400px; "
                         src=""/>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:window.history.go(-1)">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>我的朋友圈</span>
        </div>
        <div class="col"></div>
    </div>
</div>
<div style="margin:0 auto;display:none;">
    <img class="data-avt" src="">
</div>
<header>
    <img id="bg" src="/img/bg.jpeg">
    <p id="user-name" class="data-name"></p>
    <img id="avt" class="data-avt" src="/img/20160911105117_ySzuL.thumb.700_0.png">
</header>
<div id="main">
    <div id="list">
        <ul>
            <div render-loop="list">
                <li>
                    <div class="po-avt-wrap">
                        <img class="po-avt data-avt" render-src="list.user.headImgUrl">
                    </div>
                    <div class="po-cmt">
                        <div class="po-hd">
                            <p class="po-name"><span class="data-name" render-html="list.user.nickName"></span></p>
                            <div class="post">
                                <p render-html="list.comments"></p>

                                <ul class="comment-img" render-loop="list.imgArrs">
                                    <li>
                                        <img class="list-img" render-src="list.imgArrs.self" style="height: 300px;">
                                    </li>
                                </ul>

                            </div>
                            <p class="time" render-key="list.createTime" render-fun="getDate"></p>
                            <a class="userComment" data-id="" render-key="list.dynamic.id" render-fun="getDynamicId">
                                <!--评论按钮-->
                                <img class="c-icon" src="">
                            </a>
                        </div>
                        <div class="r"></div>
                        <div class="row nav-search">
                            <div class="col-9"></div>
                            <div class="col-2">
                                <a class="sss" >
                                    评论
                                    <!--<span class="glyphicon glyphicon-pencil"></span> 编辑-->
                                </a>
                            </div>
                        </div>
                    </div>
                </li>
            </div>


        </ul>
    </div>

</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <form class="form-horizontal" action="#" method="post" id="editForm">
                    <div class="col-sm-6">
                        <input type="text" class="form-control" name="sn"
                               placeholder="请输入评论内容">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
        </div>
    </div>
</div>
<script>

    function safetostring(str) {
        return String(str).replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"').replace(/&#39;/g, "'");
    }

    //$("#list").html($("#scene").html());

    setTimeout(function () {
        // $(".data-name").text(safetostring(nickname));
        //$(".data-avt").attr("src", headimgurl);
        var cw = $('.list-img').width();
        $('.list-img').css({'height': cw + 'px'});
    }, 0);

    $(window).resize(function () {
        var cw = $('.list-img').width();
        $('.list-img').css({'height': cw + 'px'});
    });


    $(document.body).show();

    //日期格式
    function getDateDetail(date) {
        var d = new Date(parseInt(date));
        var year = d.getFullYear();
        var month = d.getMonth() + 1;
        var day = d.getDate();
        var hour = d.getHours();
        var minute = d.getMinutes();

        var dNow = new Date();
        var yearNow = dNow.getFullYear();
        var monthNow = dNow.getMonth() + 1;
        var dayNow = dNow.getDate();
        var hourNow = dNow.getHours();
        var minuteNow = dNow.getMinutes();
        if (year == yearNow) {
            if (month == monthNow) {
                if (day == dayNow) {
                    if (hour == hourNow) {
                        return (minuteNow - minute) + "分钟前";
                    } else {
                        return (hourNow - hour) + "小时前";
                    }
                } else {
                    if (dayNow - day <= 3) {
                        return (dayNow - day) + "天前";
                    }
                }
            }
        }
        return year + "-" + month + "-" + day;
    }


</script>

</body>
</html>